home *** CD-ROM | disk | FTP | other *** search
/ Aminet 24 / Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso / Aminet / dev / c / cxref_1_4a.lha / file.c < prev    next >
C/C++ Source or Header  |  1997-12-07  |  3KB  |  142 lines

  1. /***************************************
  2.   $Header: /home/amb/cxref/RCS/file.c 1.10 1997/05/17 15:06:01 amb Exp $
  3.  
  4.   C Cross Referencing & Documentation tool. Version 1.4.
  5.  
  6.   Sets up the top level File structure.
  7.   ******************/ /******************
  8.   Written by Andrew M. Bishop
  9.  
  10.   This file Copyright 1995,96,97 Andrew M. Bishop
  11.   It may be distributed under the GNU Public License, version 2, or
  12.   any higher version.  See section COPYING of the GNU Public license
  13.   for conditions under which this file may be redistributed.
  14.   ***************************************/
  15.  
  16. /*+ To control the debugging in this file. +*/
  17. #define DEBUG 0
  18.  
  19. #include <stdlib.h>
  20. #include <stdio.h>
  21. #include <string.h>
  22.  
  23. #ifdef AMIGA /* olsen */
  24. #include "amiga.h"
  25. #endif /* AMIGA */
  26.  
  27. #include "memory.h"
  28. #include "datatype.h"
  29. #include "cxref.h"
  30.  
  31. /*+ This contains the File that is currently being documented to allow the other functions access to it. +*/
  32. extern File CurFile;
  33.  
  34. /*++++++++++++++++++++++++++++++++++++++
  35.   Creates a new File structure.
  36.  
  37.   File NewFile Returns the new file structure.
  38.  
  39.   char* name The name of the file.
  40.   ++++++++++++++++++++++++++++++++++++++*/
  41.  
  42. File NewFile(char* name)
  43. {
  44.  File file=(File)Calloc(1,sizeof(struct _File));
  45.  
  46.  file->name=MallocString(name);
  47.  file->inc_in=NewStringList();
  48.  file->f_refs=NewStringList2();
  49.  file->v_refs=NewStringList2();
  50.  
  51.  return(file);
  52. }
  53.  
  54.  
  55. /*++++++++++++++++++++++++++++++++++++++
  56.   Called when a file comment has been seen. Only the first of multiple comments in a file are used.
  57.  
  58.   char* comment The comment for the file.
  59.   ++++++++++++++++++++++++++++++++++++++*/
  60.  
  61. void SeenFileComment(char* comment)
  62. {
  63.  if(!CurFile->comment)
  64.     CurFile->comment=MallocString(comment);
  65. }
  66.  
  67.  
  68. /*++++++++++++++++++++++++++++++++++++++
  69.   Deletes a file structure.
  70.  
  71.   File file The file structure to be deleted.
  72.  
  73.   This is required to go through each of the elements in the File structure and delete each of them in turn.
  74.   ++++++++++++++++++++++++++++++++++++++*/
  75.  
  76. void DeleteFile(File file)
  77. {
  78.  if(file->comment) Free(file->comment);
  79.  if(file->name)    Free(file->name);
  80.  
  81.  if(file->inc_in)  DeleteStringList(file->inc_in);
  82.  if(file->f_refs)  DeleteStringList2(file->f_refs);
  83.  if(file->v_refs)  DeleteStringList2(file->v_refs);
  84.  
  85.  if(file->includes)
  86.    {
  87.     Include p=file->includes;
  88.     do{
  89.        Include n=p->next;
  90.        DeleteIncludeType(p);
  91.        p=n;
  92.       }
  93.     while(p);
  94.    }
  95.  
  96.  if(file->defines)
  97.    {
  98.     Define p=file->defines;
  99.     do{
  100.        Define n=p->next;
  101.        DeleteDefineType(p);
  102.        p=n;
  103.       }
  104.     while(p);
  105.    }
  106.  
  107.  if(file->typedefs)
  108.    {
  109.     Typedef p=file->typedefs;
  110.     do{
  111.        Typedef n=p->next;
  112.        DeleteTypedefType(p);
  113.        p=n;
  114.       }
  115.     while(p);
  116.    }
  117.  
  118.  if(file->variables)
  119.    {
  120.     Variable p=file->variables;
  121.     do{
  122.        Variable n=p->next;
  123.        DeleteVariableType(p);
  124.        p=n;
  125.       }
  126.     while(p);
  127.    }
  128.  
  129.  if(file->functions)
  130.    {
  131.     Function p=file->functions;
  132.     do{
  133.        Function n=p->next;
  134.        DeleteFunctionType(p);
  135.        p=n;
  136.       }
  137.     while(p);
  138.    }
  139.  
  140.  Free(file);
  141. }
  142.